package com.study.juc.threadpool;

public class InternalTask implements Runnable{


    private volatile boolean running =true;
    private final RunnableQueue queue;

    public InternalTask(RunnableQueue queue) {
        this.queue = queue;
    }

    @Override
    public void run() {
        while ( running && !Thread.currentThread().isInterrupted()){
            try {
                Runnable take = queue.take();
                take.run();
            } catch (InterruptedException e) {
                running =false;
                break;
            }
        }
    }
    
    public void stop(){
        this.running =false;
    }
    
}
